
{extend name="public/base" /}

{block name="title"}密码找回{/block}
{block name="column"}{/block}
{block name="content"}
<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li><a href="{:url('index/login/index')}">登入</a></li>
        <li class="layui-this">{if cache('repass')==2}重置密码{else /}找回密码{/if}</li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          

            {if cache('repass')==1}
			<div class="layui-form layui-form-pane">            
				<form id="form2">
				<div class="layui-form-item">
				  <label for="L_email" class="layui-form-label">验证码</label>
				  <div class="layui-input-inline">
					<input type="text" id="L_email" name="code" required lay-verify="required" autocomplete="off" class="layui-input">
				  </div>
				</div>
				<div class="layui-form-item">
					<button type="submit" name="submit" class="layui-btn" alert="1" lay-filter="user" lay-submit id="postcode">提交</button>
                    <span class="layui-btn" ><a href="{:url('login/forget')}">返回</a></span>
				  </div>
				</form>
			</div>
			
            {elseif cache('repass')==2 /}
			
			<!-- 重置密码 -->
			<div class="fly-msg">请重置您的密码</div>
          <div class="layui-form layui-form-pane"  style="margin-top: 30px;">
            <form id="form3">
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="password" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="repassword" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_vercode" class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_vercode" name="captcha" required lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid">
                  <span style="color: #c00;">
				  <div >
				  <img id="captcha" src="{:captcha_src()}" onclick="this.src='{:captcha_src()}?'+Math.random();"  style="float:left; cursor:pointer;"  alt="captcha" />
				  </div>
				  </span>
                </div>
              </div>
              <div class="layui-form-item">
			  <!--
                <input type="hidden" name="name" value="{{d.username}}">
                <input type="hidden" name="email" value="{{d.email}}">
				-->
                <button class="layui-btn" alert="1" lay-filter="user" lay-submit id="respass">提交</button>
              </div>
            </form>
          </div>

          <div class="fly-error">该重置密码链接已失效，请重新校验您的信息</div>
          <div class="fly-error">非法链接，请重新校验您的信息</div>
			
			{else /}
			
			<div class="layui-form layui-form-pane">
				<form method="post" id="form1">
				  <div class="layui-form-item">
					<label for="L_email" class="layui-form-label">邮箱</label>
					<div class="layui-input-inline">
					  <input type="text" id="L_email" name="email" required lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				  </div>
				  <div class="layui-form-item">
					<label for="L_vercode" class="layui-form-label">验证码</label>
					<div class="layui-input-inline">
					  <input type="text" id="L_vercode" name="captcha" required lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
					</div>
					<div class="layui-form-mid">
					  <span style="color: #c00;">
					  <div ><img id="captcha" src="{:captcha_src()}?id=1" onclick="this.src='{:captcha_src()}?id=1'+Math.random();"  style="float:left; cursor:pointer;"  alt="captcha" /></div>
					  </span>
					</div>
				  </div>
				
				  <div class="layui-form-item">
					<button type="submit" name="submit" class="layui-btn" alert="1" lay-filter="user" lay-submit id="forget">提交</button>
				  </div>
				</form>
			</div>
			{/if}
        </div>
       </div>
    </div>
   </div>
</div>
{/block}

{block name="script"}
<script>
$(function() {
	$('#forget').click(function() {
		loading = layer.load(2, {
                shade: [0.2, '#000']
            });
			$.ajax({
				type:"post",
				url:"{:url('login/forget')}",
				data:$('#form1').serialize(),
				daType:"json",
				success:function (data){
					if (data.code == 0) {
						layer.close(loading);
						layer.msg(data.msg,{
							icon:6,
							time:2000
						},function(){
							location.href = data.url;
						});
					} else {
						layer.close(loading);
						layer.open({
							tiele:'发送失败',
							content:data.msg,
							icon:5,
							anim:6
						});
						layui.jquery('#captcha').attr('src', '{:captcha_src()}?id=1'+Math.random());
					}
				}
			});
	return false;	
	});
});


$(function() {
	$('#postcode').click(function() {
		loading = layer.load(2, {
                shade: [0.2, '#000']
            });
			$.ajax({
				type:"post",
				url:"{:url('login/postcode')}",
				data:$('#form2').serialize(),
				daType:"json",
				success:function (data){
					if (data.code == 0) {
						layer.close(loading);
						layer.msg(data.msg,{
							icon:6,
							time:2000
						},function(){
							location.href = data.url;
						});
					} else {
						layer.close(loading);
						layer.open({
							tiele:'验证失败',
							content:data.msg,
							icon:5,
							anim:6
						});
					}
				}
			});
	return false;	
	});
});

$(function() {
    $('#respass').click(function() {
        loading = layer.load(2, {
            shade: [0.2, '#000']
        });
        $.ajax({
            type:"post",
            url:"{:url('login/respass')}",
            data:$('#form3').serialize(),
            daType:"json",
            success:function (data){
                if (data.code == 0) {
                    layer.close(loading);
                    layer.msg(data.msg,{
                        icon:6,
                        time:2000
                    },function(){
                        location.href = data.url;
                    });
                } else {
                    layer.close(loading);
                    layer.open({
                        tiele:'发送失败',
                        content:data.msg,
                        icon:5,
                        anim:6
                    });
                    layui.jquery('#captcha').attr('src', '{:captcha_src()}?'+Math.random());
                }
            }
        });
        return false;
    });
});


</script>
<script>
    layui.cache.page = 'user';
    layui.cache.user = {
        username: '{$user.name??'游客'}'
        ,uid: {$user.id ? 168*$user.id : -1}
        ,avatar: '{if condition="$user['user_img'] neq ''"}/uploads/{$user['user_img']}{else /}/static/res/images/avatar/00.jpg{/if}'
        ,experience: 83
        ,sex: '{if condition="$user['sex'] eq 0"}男{else/}女{/if}'
    };
    layui.config({
        version: "3.0.0"
        ,base: '/static/res/mods/'
    }).extend({
        fly: 'index'
    }).use('fly');
</script>
{/block}
